//Κλαση που κανει εφικτη τη συνδεση σε μια συγκεκριμενη βαση δεδομενων, μεσω των κλασεων DAO
package DAO;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

public class javaconnect {

    public static Connection connecrDb(String Driver, String Name) throws ClassNotFoundException {
        Connection conn = null;
        try {
            Class.forName(Driver);
            conn = DriverManager.getConnection(Name, "root", "");
            return conn;
        } catch (SQLException e) {
            JOptionPane.showMessageDialog(null, "Database not found, try again.Program will shut down.", "javaconnect", JOptionPane.INFORMATION_MESSAGE);
            return null;
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(javaconnect.class.getName()).log(Level.SEVERE, null, ex);
            return null;

        }
    }

}
